﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace _3D_Game2
{
    class SpinningEnemy: BasicModel
    {
        Matrix rotation = Matrix.Identity;
        Matrix Scale = Matrix.Identity;
        Matrix Translation = Matrix.Identity;
        float scale = 1;
        float yawAngle = 0;
        float pitchAngle = 0;
        float rollAngle = 0;
        Vector3 direction;
        Vector3 position;
        float angle;
        float speed = 3.0f;
        //Vector3 myposition;

        public SpinningEnemy(Model m, Vector3 Position,Vector3 Direction, float yaw, float pitch, float roll, float scale)
            : base(m)
        {
            world*= Matrix.CreateTranslation(Position);
            yawAngle = yaw;
            pitchAngle = pitch;
            rollAngle = roll;
            direction = Direction;
            //direction.Normalize();
            this.scale = scale;
            Scale*= Matrix.CreateScale(scale);
           // Translation = Matrix.CreateTranslation(direction) * speed;
        }

        public override void Update()
        {
            //// Rotate model
            //rotation *= Matrix.CreateFromYawPitchRoll(yawAngle,
            //pitchAngle, rollAngle);
            //// Move model
            //world = Scale * Matrix.CreateTranslation(direction);
            //myposition.Z += speed;
            angle = MathHelper.Pi;
            //Scale = Matrix.CreateScale(0.5f);
            //world = Scale * Matrix.CreateRotationX(angle) * Matrix.CreateRotationZ(angle)  * Matrix.CreateTranslation(position);
            //world= Scale * Matrix.CreateTranslation(direction);

            world *= Matrix.CreateTranslation(direction);
        }

        public override Matrix GetWorld()
        {
            return Scale * rotation * world;
        }
    }
}
